home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************\
- CWASTETask.cpp
-
- A task for dealing with undo for CWASTEText objects under WASTE 1.1
-
- by Dan Crevier
- 11/4/95
-
- version 1.8
-
- based on code by Jud Spencer
-
- Roms 95/11/08 adapted to THINK C / TCL 1.1.3
- \************************************************************************/
-
- #include "CWASTETask.h"
- #include "CWASTEText.h"
-
- #define undoDrag 6
-
- /************************************************************************\
- Constructor - save a pointer to the CWASTEText
- \************************************************************************/
-
- #ifndef THINK_C
- CWASTETask::CWASTETask(CWASTEText *text)
- : CTask(0)
- {
- #else
- void CWASTETask::IWASTETask(CWASTEText *text)
- {
- ITask(0);
- #endif // THINK_C
- wasteText = text;
- }
-
- /************************************************************************\
- Destructor - tell text object that we aren't around any more
- \************************************************************************/
-
- #ifndef THINK_C
- CWASTETask::~CWASTETask()
- #else
- void CWASTETask::Dispose()
- #endif // THINK_C
- {
- if (wasteText->itsLastTask == this)
- wasteText->itsLastTask = NULL;
-
- #ifdef THINK_C
- CTask::Dispose();
- #endif
-
- }
-
- /************************************************************************\
- GetNameIndex - give a pointer to the name of the undo action
- \************************************************************************/
-
- short CWASTETask::GetNameIndex()
- {
- short offset = -1;
- Boolean undone;
-
- switch (wasteText->GetUndoInfo(&undone))
- {
- case weAKTyping:
- offset = undoTyping;
- break;
-
- case weAKCut:
- offset = undoCut;
- break;
-
- case weAKPaste:
- offset = undoPaste;
- break;
-
- case weAKClear:
- offset = undoClear;
- break;
-
- case weAKDrag:
- offset = undoDrag;
- break;
-
- case weAKSetStyle:
- offset = undoFormatting;
- break;
- }
- if ( offset >= 0)
- {
- return (offset + CWASTEText::cFirstTaskIndex);
- }
- else
- {
- return ( 0);
- }
- }
-
- /************************************************************************\
- Undo - tell the CWASTEText to call WEUndo()
- \************************************************************************/
-
- void CWASTETask::Undo()
- {
- wasteText->BecomeGopher(true);
- wasteText->Prepare();
- wasteText->DoUndo();
- wasteText->AdjustBounds();
- wasteText->ScrollToSelection();
- }
-
- /************************************************************************\
- IsUndone - return true if it's a "redo"
- \************************************************************************/
-
- Boolean CWASTETask::IsUndone()
- {
- Boolean undone;
-
- wasteText->GetUndoInfo( &undone);
-
- return undone;
- }
-